<#include '/admin/header.html' > 
<#assign dateFormat="com.enation.framework.directive.DateformateDirective"?new()>
<div id="loading"></div>
	<div class="main">
		<form id="orderform">
			<div class='buttonArea'>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true" id="cleanBtn">清除</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true" id="revertBtn">还原</a>
			</div>
			<div class="clear height10"></div>
			<div class="shadowBoxWhite tableDiv">
					<table class="easyui-datagrid"
						data-options="url:'order!trash_listJson.do',remoteSort:false,pageList: [5,10,15,20],pageSize:${pageSize},fitColumns:'true'"
						pagination="true" width="width" id="orderdata">
						<thead>
							<tr>
								<th data-options="field:'order_id',checkbox:true,width:100"></th>
								<th data-options="field:'sn',width:150">订单号</th>
								<th data-options="field:'create_time',width:100,sortable:true" formatter="formatDate">下单日期</th>
								<th data-options="field:'sale_cmpl_time',width:100,sortable:true" formatter="formatDate">发货日期</th>		
								<th data-options="field:'need_pay_money',width:100,sortable:true" formatter="forMoney">订单总额</th>
								<th data-options="field:'paymoney',width:100,sortable:true" formatter="forMoney">实付金额</th>
								<th data-options="field:'ship_name',width:100">收货人</th>
								<th data-options="field:'status',width:100,sortable:true" formatter="forStruts">订单状态</th>
								<th data-options="field:'pay_status',width:100,sortable:true" formatter="forpay">付款状态</th>
								<th data-options="field:'ship_status',width:100,sortable:true" formatter="forship">发货状态</th>
								<th data-options="field:'shipping_type',width:100,sortable:true">配送方式</th>
								<th data-options="field:'payment_name',width:100,sortable:true">支付方式</th>
							</tr>
						</thead>
					</table>
				</div>
		</form>
	</div>
<script type="text/javascript">
//金额
function forMoney(value, row, index) {
	var val = "￥" + value;
	return val;
}
//日期
function formatDate(value,row,index){
	if(value==null||value==0){
		return "";
	}
	else{
		return getFormatDateByLong(value, "yyyy-MM-dd");
	}
}
//订单状态
function forStruts(value, row, index) {
	var val;
	val = getType(${status_Json},value);
	return val;
}

//付款状态
function forpay(value,row,index){
	var val;
	val = getType(${payStatus_Json},value);
	return val;
}

//发货状态
function forship(value,row,index){
	var val;
	val = getType(${ship_Json},value);
	return val;
}


function getType(exMap,value){
	var val;
	$.each(exMap,function(key,values){ 
	    if(value==key){
	    	val=values;
	    }
	});
	return val;
}
$(function(){
	$("#cleanBtn").click(function(){
		var rows = $('#orderdata').datagrid("getSelections");
		if (rows.length < 1) {
			$.Loading.error("请选择要删除的订单");
			return;
		}
		if (!confirm("确认要将这些订单彻底删除吗？删除后将不可恢复？")) {
			return;
		}
		$("#cleanBtn").linkbutton("disable");
		var options = {
				url : "order!clean.do?ajax=yes",
				type : "POST",
				dataType : 'json',
				success : function(result) {
					if (result.result == 1) {
						$.Loading.success(result.message);
						$('#orderdata').datagrid("reload");
						$('#orderdata').datagrid('clearSelections');
					}
					if (result.result == 0) {
						$.Loading.success(result.message);
					}
					$("#cleanBtn").linkbutton("enable");
				},
				error : function(e) {
					$.Loading.error("出现错误 ，请重试");
					$("#cleanBtn").linkbutton("enable");
				}
			};
		$('#orderform').ajaxSubmit(options);
	});
	$("#revertBtn").click(function(){
		var rows = $('#orderdata').datagrid("getSelections");
		if (rows.length < 1) {
			$.Loading.error("请选择要还原的订单");
			return;
		}
		if (!confirm("确认要将这些订单还原吗？")) {
			return;
		}
		$("#revertBtn").linkbutton("disable");	
		var options = {
				url : "order!revert.do?ajax=yes",
				type : "POST",
				dataType : 'json',
				success : function(result) {
					if (result.result == 1) {
						$.Loading.success(result.message);
						$('#orderdata').datagrid("reload");
						$('#orderdata').datagrid('clearSelections');
					}
					if (result.result == 0) {
						$.Loading.error(result.message);
					}
					$("#revertBtn").linkbutton("enable");	
				},
				error : function(e) {
					$.Loading.error("出现错误 ，请重试");
					$("#revertBtn").linkbutton("enable");	
				}
			};
			$('#orderform').ajaxSubmit(options);
	});
})


</script>
<#include '/admin/footer.html' >